<template>
  <el-option
    v-for="item in list"
    :label="$t(item)"
    :value="valueKey ? item : item[value]"
    :disabled="item[disabled]"
  ></el-option>
</template>

<script lang="ts" setup>
import { useI18n } from 'vue-i18n'

const props = withDefaults(
  defineProps<{
    i18n?: boolean
    i18nPrefix?: string
    list?: AnyObject[]
    valueKey?: string
    label?: string
    value?: string
    disabled?: string
    mult?: string
  }>(),
  {
    list: () => [],
    label: 'name',
    value: 'id',
    mult: 'mult',
    disabled: 'disabled'
  }
)

const { t } = useI18n()
const $t = (item: AnyObject) => {
  const label = item[props?.label]
  const mult = item[props?.mult]
  return props.i18n && mult ? t((props.i18nPrefix ? props.i18nPrefix + '.' : '') + mult) : label
}
</script>

<style lang="scss"></style>
